// require(["./requirejs.config"], () => {
// 	require(["jquery", "item", "url", "header"], ($, item, url, headerPromise) => {
// 		headerPromise.then(() => {
// 			console.log($(".logo"));
// 		});
// 	})
// })

require(["config"],function(){
    require(["jquery","template","loadHF","cookie"],function($ ,templat){
      function Index(){
        this.init();
        // $.cookie.json = true;
       
        console.log("..............................")
        console.log($(".usered"))
      
    }

    Index.prototype = {
      constructor:Index,
        init(){
            this.wrapshow();
            this.addHref();
            this.search();
        },
        wrapshow(){

          $(".he-nav-bd .qqqqq").hover( function(){

            $(".he-nav-bd .main_cate_l").stop(true).animate({
              opacity: "1" },
            {
              queue: false,
              duration: 1000
              // step: function( now, fx ){
              //   $( ".block:gt(0)" ).css( "left", "200" );
              }),
  
              $(".he-nav-bd .main_cate_l").slideDown(900);
              
              
            },


            
            () => {
               
                $(".he-nav-bd .main_cate_l").stop(true).animate({
                  opacity: "0.2" },
                {
                  queue: false,
                  duration: 1000 })
                  $(".he-nav-bd .main_cate_l").slideUp({ queue: false, duration: 900 });
              })






              $(".he-nav-bd .main_cate_l").hover( function(){
  
                $(this).stop().show()
                
              },
              () => {
                  $(".he-nav-bd .main_cate_l").stop().slideUp(1000);
                  
                })

            

        
        
          // $(".he-nav-bd").on("mouseover",   () => {
  
          //   $(".he-nav-bd .main_cate_l").stop().slideDown(200);
            
          // })
          // $(".he-nav-bd").on("mouseout",() => {
            
          //   $(".he-nav-bd .main_cate_l").stop().slideUp(300);
            
          // })


        },

        addHref(){
          console.log("list假数据渲染");
          $.get("http://rap2api.taobao.org/app/mock/124172/raincolor",(res)=>{
            console.log(res);
            console.log(res.array);

            const da = {da:res.array};
            const html = templat("index-template",da);
            // console.log(html);
            $(".indexerlizi").find("ul").html(html)
          })

        },

        search(){
          
          $(".sea_submit").on("click",()=>{

            var show=$(".sea_input").val()
            console.log("出来吧皮卡丘")
            console.log( $(".sea_input").val())
            $.get("http://rap2api.taobao.org/app/mock/124172/list",(res)=>{
              console.dir(res.res_body.data);
            
               var admins=[];
              
                res.res_body.data.map(function (track) {
                    
                    if(track.title.indexOf(show) != -1){
                        admins.push(track);
                       
                    }
                    
                 })
                 $.cookie.json = true;
                 console.log(admins)

                 $.cookie("search", admins, {expires: 10, path: "/"})
                  // 或短路
                  let sear = $.cookie("search") || []; 
                 console.log("sear------");
                  console.log(sear);
                
                
                
                 if (sear.length!=0) {
                  
                  // jscookie.set('search',JSON.stringify(admins))
                  // jscookie.get('seach')
                  // 把数据放入cookies
                 
                //   $.cookie("search", admins, {expires: 10, path: "/"})
                //   // 或短路
                //   let sear = $.cookie("search") || []; 
                //  console.log("sear------");
                //   console.log(sear);
                  window.location.href="/html/list.html"

                }
                




                //  const data = {products: admins};
                //     const html1 = templat("list-template",data);
                //      $(".list-pro").html(html1)
                     
             }) 
             

          })
         

        }
        


      

      }

     
        new Index();
     

     

    })
})



